package org.qiancizhan.Controller;

import org.qiancizhan.Mapper.VocabularyMapper;
import org.qiancizhan.Model.POJO.VocabularyListPOJO;

import java.util.List;

public class VocabularyListController {
    private final VocabularyMapper vocabularyMapper = new VocabularyMapper();
    //获取所有词书
    public List<VocabularyListPOJO> getVocabularyList(){
        return vocabularyMapper.getVocabularyList();
    }

    //获取用户词书
    public List<VocabularyListPOJO> getUserVocabularyList(){
        return vocabularyMapper.getUserVocabularyList();
    }
    //获取用户已添加的词书
    public VocabularyListPOJO getVocabularyUserListById(int vocabulary_list_id){
        return vocabularyMapper.getVocabularyUserListById(vocabulary_list_id);
    }
    //添加用户词书
    public boolean addUserVocabularyList(int vocabulary_list_id){
        VocabularyListPOJO vocabularyBook = getVocabularyUserListById(vocabulary_list_id);
        return vocabularyBook == null ? vocabularyMapper.addUserVocabularyList(vocabulary_list_id) : false;
    }

    //删除用户词书
    public boolean deleteUserVocabularyList(int vocabulary_list_id){
        return vocabularyMapper.deleteUserVocabularyList(vocabulary_list_id);
    }
}
